package com.itheima.线程池.mythreadpool.demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MyThreadPoolDemo1 {
    public static void main(String[] args) {
        //创建一个默认的线程池对象,池中默认是空的,默认最多可以容纳int类型的最大值
        ExecutorService executorService = Executors.newCachedThreadPool();

        executorService.submit(() ->{
            look();
        });

        executorService.submit(() ->{
            look();
        });
        //关闭线程池对象
        executorService.shutdown();
    }

    private static void look() {
        System.out.println(Thread.currentThread().getName() + "执行了");
    }
}
